<?php
namespace Home\Controller;
use Think\Controller;
class UserController extends Controller {
     public function search(){
        $this->display();
    }
    public function result() {
        $m=D("user");
        $date=$m->where($_POST)->find();
        $this->assign("vo", $date);
        $this->display();
    }
     public function addadmin() {
        if(IS_POST)
        {
            $m=D("admin");
            if($m->add($_POST))
            {
                $this->success("添加成功");
            }
            else
                $this->error("添加失败");
        }
        else
            $this->display();
    }
    public function adminlist(){
         $m=M("admin");
       $count= $m->count();
       $Page= new \Think\Page($count,3);
        $Page -> setConfig('first','首页');
        $Page -> setConfig('last','共%TOTAL_ROW%条%TOTAL_PAGE%页');
        $Page -> setConfig('prev','上一页');
        $Page -> setConfig('next','下一页');
        $Page -> setConfig('link','indexpagenumb');//pagenumb 会替换成页码
        $Page -> setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER% ');
       $show= $Page->show();// 分页显示输出// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
       $list = $m->limit($Page->firstRow.','.$Page->listRows)->select();
       $this->assign("start",$Page->firstRow);
       $this->assign('list',$list);// 赋值数据集
       $this->assign('page',$show);// 赋值分页输出
       $this->display(); // 输出模板
    }
     public function deladmin($id){
             $m=D("admin");
             if($m->where(array("admin_id"=>$id))->delete())
             {
                 $this->success("删除成功");
             }
             else
              $this->error("删除失败");
    }
    public function waitforcheckuser() {
        $m=D("user");
        $count=$m->where(array("ischekd"=>"待审核"))->count();
        $Page= new \Think\Page($count,3);
        $Page -> setConfig('first','首页');
        $Page -> setConfig('last','共%TOTAL_ROW%条%TOTAL_PAGE%页');
        $Page -> setConfig('prev','上一页');
        $Page -> setConfig('next','下一页');
        $Page -> setConfig('link','indexpagenumb');//pagenumb 会替换成页码
        $Page -> setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER% ');
       $show= $Page->show();// 分页显示输出// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
       $list = $m->limit($Page->firstRow.','.$Page->listRows)->where(array("ischekd"=>"待审核"))->select();
       $this->assign("start",$Page->firstRow);
       $this->assign('list',$list);// 赋值数据集
       $this->assign('page',$show);// 赋值分页输出
       $this->display(); // 输出模板
    }
    public function check($id){
         $m=D("User");
        if($m->save(array("student_id"=>$id,"ischeckd"=>"已审核"))){
            $this->redirect("User/waitforcheckuser",0);
        }
        
    }
    public function discheck($id){
        $m=D("User");
        $m->where(array("student_id"=>$id))->delete();
        $this->redirect("User/waitforcheckuser",0);
    }
}